﻿using Cl.Entity.DataBaseEntity.User;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cl.Entity.WorkflowEntity
{
    /// <summary>
    /// Elsa自带的表，记录每一个流程正在执行的实例
    /// </summary>
    [SugarTable("WORKFLOWINSTANCES")]
    public class WorkflowInstances
    {
        /// <summary>
        /// ID;GUID
        /// </summary>
        [SugarColumn(ColumnName = "ID", IsPrimaryKey = true)]
        public string Id { get; set; } = Guid.NewGuid().ToString();
        /// <summary>
        /// ID;GUID
        /// </summary>
        [SugarColumn(ColumnName = "DEFINITIONID")]
        public string DefinitionId { get; set; } = Guid.NewGuid().ToString();

        [SugarColumn(ColumnName = "VERSION")]
        public int Version { get; set; }

        [SugarColumn(ColumnName = "WORKFLOWSTATUS")]
        public int WorkflowStatus { get; set; }

        [SugarColumn(ColumnName = "CORRELATIONID")]
        public string CorrelationId { get; set; } = Guid.NewGuid().ToString();

        [SugarColumn(ColumnName = "CONTEXTTYPE")]
        public string? ContextType { get; set; }

        [SugarColumn(ColumnName = "CONTEXTID")]
        public string? ContextId { get; set; }

        [SugarColumn(ColumnName = "NAME")]
        public string? Name { get; set; }

        [SugarColumn(ColumnName = "CREATEDAT")]
        public DateTime CreatedAt { get; set; }

        [SugarColumn(ColumnName = "DEFINITIONVERSIONID")]
        public string DefinitionVersionId { get; set; } = Guid.NewGuid().ToString();

        [SugarColumn(ColumnName = "DATA")]
        public string Data { get; set; } = string.Empty;

        #region 导航 1vN
        [Navigate(NavigateType.OneToMany, nameof(UserApproFlowMap.ApproflowId), nameof(Id))]
        public List<UserApproFlowMap>? UserApproFlowMaps { get; set; }
        #endregion
    }
}
